class Solution
{
public:
    string getSmallestString(int n, int k)
    {
        string result;
        result.reserve(n);
        char c = 'a';
        while (n)
        {
            if ((n - 1) * 26 >= k - (c - 'a' + 1))
            {
                result += c;
                --n;
                k -= c - 'a' + 1;
            }
            else
            {
                ++c;
                if (c == 'z')
                {
                    result.append(n, 'z');
                    break;
                }
            }
        }
        return result;
    }
};